# -*- coding: utf-8 -*-
# @Time    : 2024/12/1 下午3:17
# @Author  : wjx
# @Email   : kanxinxin@163.com
# @File    : redact_diet_page.py
# @Software: PyCharm
from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


class RedactDietPage(BasePage):
    # 定位器
    # 设置
    settings_btn_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().description("设置")')
    # 早餐
    breakfast_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().description("早餐")')
    # 搜索
    search_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().description("请输入食物名称")')
    # 取消
    dismiss_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().description("取消")')
    # 鸡蛋
    egg_select_locator = (By.XPATH, '//android.view.View[@content-desc="鸡蛋 热量 139 千卡 / 100 克 碳水 2.4 克 / 100 克"]')
    # 确定
    sure_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().description("确定")')
    # 完成
    finish_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().description("完成")')
    # 清理环境
    # 添加的鸡蛋
    added_diet_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().description("鸡蛋 1 个 83 千卡")')
    # 删除这条记录
    delete_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().description("删除这条记录")')
    # 点击删除
    sure_delete_locator = (By.ANDROID_UIAUTOMATOR,'new UiSelector().description("删除")')

    def click_settings_btn(self):
        """
        点击设置按钮
        :return: None
        """
        self.find_element(self.settings_btn_locator).click()

    def click_breakfast(self):
        """
        点击早餐按钮
        :return:
        """
        self.find_element(self.breakfast_locator).click()

    def click_search(self):
        """
        点击搜索
        :return:None
        """
        self.find_element(self.search_locator).click()

    def click_dismiss(self):
        """
        点击取消
        :return:None
        """
        self.find_element(self.dismiss_locator).click()

    def click_egg_select(self):
        """
        点击选择鸡蛋
        :return: None
        """
        self.find_element(self.egg_select_locator).click()

    def click_sure_btn(self):
        """
        点击确定
        :return:None
        """
        self.find_element(self.sure_locator).click()

    def click_finish_btn(self):
        """
        点击完成
        :return: None
        """
        self.find_element(self.finish_locator).click()

    def click_added_diet(self):
        """
        点击添加的记录
        :return: None
        """
        self.find_element(self.added_diet_locator).click()

    def click_delete(self):
        """
        点击删除这条记录
        :return: None
        """
        self.find_element(self.delete_locator).click()

    def click_sure_delete(self):
        """
        点击确定删除
        :return:None
        """
        self.find_element(self.sure_delete_locator).click()

